//
//  UIViewAdditions.h
//  Weibo
//
//  Created by junmin liu on 10-9-29.
//  Copyright 2010 Openlab. All rights reserved.
//

#import <Foundation/Foundation.h>

typedef void(^UIViewTapResultBlock) (BOOL result);
typedef void(^UIViewLongPressResultBlock) (BOOL result);

@interface UIView (Addtions)
- (id)roundCornersOnTopLeft:(BOOL)tl topRight:(BOOL)tr bottomLeft:(BOOL)bl bottomRight:(BOOL)br radius:(float)radius;

/**
 * Shortcut for frame.origin.x.
 *
 * Sets frame.origin.x = left
 */
@property (nonatomic) CGFloat left;

/**
 * Shortcut for frame.origin.y
 *
 * Sets frame.origin.y = top
 */
@property (nonatomic) CGFloat top;

/**
 * Shortcut for frame.origin.x + frame.size.width
 *
 * Sets frame.origin.x = right - frame.size.width
 */
@property (nonatomic) CGFloat right;

/**
 * Shortcut for frame.origin.y + frame.size.height
 *
 * Sets frame.origin.y = bottom - frame.size.height
 */
@property (nonatomic) CGFloat bottom;

/**
 * Shortcut for frame.size.width
 *
 * Sets frame.size.width = width
 */
@property (nonatomic) CGFloat width;

/**
 * Shortcut for frame.size.height
 *
 * Sets frame.size.height = height
 */
@property (nonatomic) CGFloat height;

/**
 * Shortcut for center.x
 *
 * Sets center.x = centerX
 */
@property (nonatomic) CGFloat centerX;

/**
 * Shortcut for center.y
 *
 * Sets center.y = centerY
 */
@property (nonatomic) CGFloat centerY;

/**
 * Return the x coordinate on the screen.
 */
@property (nonatomic, readonly) CGFloat ttScreenX;

/**
 * Return the y coordinate on the screen.
 */
@property (nonatomic, readonly) CGFloat ttScreenY;

/**
 * Return the x coordinate on the screen, taking into account scroll views.
 */
@property (nonatomic, readonly) CGFloat screenViewX;

/**
 * Return the y coordinate on the screen, taking into account scroll views.
 */
@property (nonatomic, readonly) CGFloat screenViewY;

/**
 * Return the view frame on the screen, taking into account scroll views.
 */
@property (nonatomic, readonly) CGRect screenFrame;

/**
 * Shortcut for frame.origin
 */
@property (nonatomic) CGPoint origin;

/**
 * Shortcut for frame.origin.y
 */
@property (nonatomic) CGFloat originY;

/**
 * Shortcut for frame.size
 */
@property (nonatomic) CGSize size;

/** Tap手势  */
@property (nonatomic, copy) UIViewTapResultBlock tapResultBlock;
@property (nonatomic, strong) UITapGestureRecognizer *tapGestureRecognizer;

/**< 长按手势 */
@property (nonatomic, copy) UIViewLongPressResultBlock longPressResultBlock;
@property (nonatomic, strong) UILongPressGestureRecognizer *longPressGestureRecognizer;

- (UIImage*)screenshot;
- (UIImage*)screenshotOptions;
- (UIImage*)screenshotWithSize:(CGSize)size;
- (UIView*)descendantOrSelfWithClass:(Class)cls;

- (UIView*)ancestorOrSelfWithClass:(Class)cls;

- (void)removeAllSubviews;

- (UIImage *)imageByRenderingView;

+ (instancetype)viewFromXib;

/** 显示占位图片 */
@property (nonatomic, strong) UIView * placeHolderView;
- (void)showPlaceholderView:(BOOL)show text:(NSString *)text image:(UIImage *)image;

- (void)addSubviews:(NSArray *)objects;

@end
